package GUI;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JButton;

import Controller.ComplaintHandelingController;
import Controller.DBcontroller;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.WindowEvent;

/**
 * this is the GUI for customer service worker. it has only two buttons for viewing the former complaint and for handeling a compliant.
 * @author Moran Abilea
 *
 */
public class CustomerServiceWorkerGUI extends JPanel {
	JPanel cur=this;
	JFrame frame;
	JPanel lastPanel;
	public void setLastPanel (JPanel panel)
	{
		this.lastPanel=panel;
	}
	public void setFrame (JFrame frame)
	{
		this.frame=frame;
	}

	/**
	 * is the constructor. it has two buttons and it will transfer us to the right option GUI.
	 */
	public CustomerServiceWorkerGUI() {
		
		setBounds(100, 100, 915, 410);
		
		setBorder(new EmptyBorder(5, 5, 5, 5));
		setLayout(null);
		
		JLabel lblWelcomeToComplaint = new JLabel("Welcome, Mr. service class worker!");
		lblWelcomeToComplaint.setFont(new Font("Tahoma", Font.PLAIN, 18));
		lblWelcomeToComplaint.setBounds(313, 79, 331, 39);
		add(lblWelcomeToComplaint);
		
		JButton btnHandlingComplaints = new JButton("Handling Complaints");
		btnHandlingComplaints.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				CustomerComplaintHandelingBoundary openhandle=new CustomerComplaintHandelingBoundary(ComplaintHandelingController.getCustomerComplaintsForHandeling(DBcontroller.getLoggedIn()));
				openhandle.setFrame(frame);
				openhandle.setLastPanel(cur);
				openhandle.setVisible(true);
			}
		});
		btnHandlingComplaints.setBounds(279, 224, 167, 23);
		add(btnHandlingComplaints);
		
		JLabel lblPleaseChooseYou = new JLabel("Please choose you option");
		lblPleaseChooseYou.setBounds(390, 165, 157, 14);
		add(lblPleaseChooseYou);
		
		JButton btnViewingResultComplaints = new JButton("Viewing Result Complaints");
		btnViewingResultComplaints.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				CustomerHandelingViewBoundary viewhandle=new CustomerHandelingViewBoundary(ComplaintHandelingController.getCustomerComplaintsHandeled(DBcontroller.getLoggedIn()));
				viewhandle.setFrame(frame);
				viewhandle.setLastPanel(cur);
				viewhandle.setVisible(true);
			}
		});
		btnViewingResultComplaints.setBounds(467, 224, 198, 23);
		add(btnViewingResultComplaints);
		
		JButton btnLogout = new JButton("logout");
		btnLogout.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				frame.setContentPane((JPanel)lastPanel);
			}
		});
		btnLogout.setBounds(407, 332, 89, 23);
		add(btnLogout);
	}
}